package com.lap.framework.generator.infra.query;

import com.lap.framework.generator.domain.valueobject.TypeModel;

public class JavaTypeMapper {

  private JavaTypeMapper() {}

  public static TypeModel map(String dbType, String maxLength) {
    return switch (dbType.toLowerCase()) {
      case "tinyint" -> TypeModel.of("Integer", "-127", "128");
      case "smallint" -> TypeModel.of("Integer", "-32768", "32767");
      case "integer", "int" -> TypeModel.of("Integer", "0", String.valueOf(Integer.MAX_VALUE));
      case "bigint" -> TypeModel.of("Long", "0", String.valueOf(Integer.MAX_VALUE));
      case "decimal", "numeric" ->
          TypeModel.of("BigDecimal", "0", String.valueOf(Integer.MAX_VALUE));
      case "float", "double" -> TypeModel.of("Double", "0", String.valueOf(Integer.MAX_VALUE));
      case "date" -> TypeModel.of("LocalDate", null, null);
      case "datetime", "timestamp" -> TypeModel.of("LocalDateTime", null, null);
      case "time" -> TypeModel.of("LocalTime", null, null);
      case "bit", "boolean" -> TypeModel.of("Boolean", null, null);
      default -> TypeModel.of("String", null, maxLength);
    };
  }
}
